<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>列表展示</title>
    <!-- 引入 layui.css -->
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.6/dist/css/layui.css">
</head>
<body>
<select id="sel">
    {foreach $data1 as $v}
    <option value="{$v->id}">{$v->type_name}</option>
    {/foreach}
</select>
<table class="layui-table">

    <colgroup>
        <col width="150">
        <col width="200">
        <col>
    </colgroup>
    <thead>
    <tr>
        <th>编号</th>
        <th>商品名</th>
        <th>价格</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach $data as $v}
    <tr>
        <td>{$v->id}</td>
        <td id="name">{$v->g_name}</td>
        <td>{$v->g_price}</td>
        <td><a>修改</a>/<a>删除</a></td>
    </tr>
    {/foreach}
    </tbody>
</table>
<script src="//unpkg.com/layui@2.6.6/dist/layui.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
</script>
<script>
    layui.use('element', function(){
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块

        //监听导航点击
        element.on('nav(demo)', function(elem){
            //console.log(elem)
            layer.msg(elem.text());
        });
    });


    $(function () {
        $("#name").click(function () {
            let g_name = $(this).html();

            $(this).html('<input type="text"  name="g_name"  class="input">')
            $('.input').val(g_name);


        });

        $('.input').blur(function () {
            console.log(123);
        })


        $("#sel").blur(function () {
            var  id = $(this).val();

            $.ajax({
                url:"{:url('type')}",
                dataType:'json',
                data:{id:id},
                success:function (res) {
                    var $data = res.data;

                    window.location.href('/test510/goods/type');
                    //将查询的数据展示到页面上


                }
            })
        })
    })
</script>
</body>
</html>
<!-- 引入 layui.js -->
